package com.lv.jie.controller;

import com.lv.jie.pojo.User;
import com.lv.jie.service.UserService;
import com.lv.jie.utils.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author dell
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @ApiOperation("发送验证码")
    @GetMapping("/SendVerificationCode")
    public JsonResult sendVerificationCode(String email){
        return userService.sendVerificationCode(email);
    }

    @ApiOperation("验证验证码")
    @GetMapping("/confirm")
    public JsonResult confirm(String email, String code){
        return userService.confirm(email, code);
    }

    @ApiOperation("根据id查询用户")
    @GetMapping("/selectUserById")
    public JsonResult selectUserById(Integer id, String token){
        return userService.selectUserById(id, token);
    }

    @ApiOperation("修改用户信息")
    @PutMapping("/updateUser")
    public JsonResult updateUser(User user, String token){
        return userService.updateUser(user, token);
    }
}
